layui.use(['form','layer','upload','layedit'],function(){
	   var form = layui.form
       layer = parent.layer === undefined ? layui.layer : top.layer,
       $ = layui.jquery,
       laydate = layui.laydate,
       laytpl = layui.laytpl,
       upload = layui.upload;
	   var layedit = layui.layedit;
  
	    //普通图片上传
	    var uploadInst = upload.render({
	    	elem: '#test1'
	            ,url: 'https://www.idjglobalapp.com/app-servce/v1/api/upload' //改成您自己的上传接口
	            ,method: 'POST'
	            ,done: function(res){
	                //上传完毕
	                if(res.code == 1){
	                	$('#demo1').attr('src', res.data);
	                	var imgId = $("#imgId").val();
	                	var url = res.data;
	                	var data = {
	        	    			id: imgId,
	        	    			url: url,
	        	    			type:1,
	        	    			orderby : 1
	        	    	}
	                	var urls ="";
	                	if(imgId == ''){
	                		urls ="/modular/images/insert";
	                	}else{
	                		urls ="/modular/images/update";
	                	}
	                   	$.ajax({
	        	    		url: Feng.ctxPath + urls,
	        	    		data: JSON.stringify(data),
	        	    		type: "post",
	        	    		contentType: "application/json;charset=UTF-8",
	        	    		async: false,//关闭异步请求
	        	    		dataType: "json",
	        	    		success: function (data) {
	        	    			if (data.code == 200) {
	        	    				Feng.success('上传成功')
	        	    			} else {
	        	    				Feng.error("操作失败");
	        	    			}
	        	    		}
	        	    	});
	                }
	             }
	    });
	    
});